﻿@{ ViewBag.Title = "Index";
    Layout = "~/Areas/Shared/_LayuiList.cshtml"; }

<input style="display:none" id="tbid" value="@ViewBag.tbid">
<!--数据表格-->
<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>

<script src="~/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="~/js/lay-config.js?v=2.0.0" charset="utf-8"></script>
<script>
    layui.use(["table", "form", "exLayer", "exUtils"], function () {
        let table = layui.table;
        let form = layui.form;
        let exLayer = layui.exLayer;
        let exUtils = layui.exUtils;
        let miniPage = layui.miniPage;

        let $ = layui.$;

        let ThisTable = table.render({
            elem: "#tableId",
            url: "/SysTable/TbRelation/GetIndexAndParameterList?tbid=" + $("#tbid").val(),
            method: "get",
            height: 300, //容器高度
            page: false,
            toolbar: "#toolbarTpl",
            cols: [[
                { type: "radio", fixed: 'left' },
                { field: "Text", title: "" }
            ]],
            done: function (res, curr, count) {
                $('th').hide();//表头隐藏的样式
            }
        });

        table.on("toolbar(tableFilter)", function (obj) {
            switch (obj.event) {
                case "OK":
                    getSelect(obj);
                    break;
            }
        });

        //确定选择
        function getSelect(obj) {
            var strv = "";
            var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
            if (checkStatus.data.length > 0) {
                strv = checkStatus.data[0].Value;
            }
            $(window.parent.document).find('#valuekey').val(strv);
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        }
    });
</script>
<script type="text/html" id="toolbarTpl">
    <button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="OK" id="OK">确定选择</button>
</script>